package shizhan;

import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.util.Iterator;
import java.util.List;

public class Shizhan5 {
    public static void main(String[] args) throws DocumentException {
        SAXReader saxReader=new SAXReader();

        Document document=saxReader.read("src/shizhan/Phone.xml");

        Element root = document.getRootElement();
        for (Iterator itBrand = root.elementIterator(); itBrand.hasNext();){
            Element brand =(Element) itBrand.next();
            System.out.println("品牌："+brand.attributeValue("name"));
            for (Iterator itType=brand.elementIterator();itType.hasNext();){
                Element type=(Element) itType.next();
                System.out.println("\t型号："+type.attributeValue("name"));
            }
        }
    }
}
